<template>
  <div class="app-container">





      <el-row :gutter="15">
        <el-form
          ref="elForm"
          :model="formData"
          :rules="dialogrules"
          size="medium"
          label-width="100px"
          label-position="left"
        >
          <el-col :span="12">
            <el-form-item label="题目类型" prop="type">
              <el-input
                v-model="formData.type"
                placeholder="请输入题目类型"
                :disabled="true"
                clearable
                :style="{width: '100%'}"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所属题库" prop="bankTypeId">
              <el-select
                v-model="formData.bankTypeId"
                default-first-option
                placeholder="请选择模板"
                clearable
                :style="{width: '100%'}"
              >
                <el-option
                  v-for="(item, index) in questionBankType"
                  :key="index"
                  :label="item.name"
                  :value="item.id"
                  :disabled="item.disabled"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24"></el-col>
          <el-col :span="12">
            <el-form-item label="难易程度" prop="difficulty">
              <el-select
                v-model="formData.difficulty"
                placeholder="请选择难易程度"
                clearable
                :style="{width: '100%'}"
              >
                <el-option
                  v-for="(item, index) in field103Options"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                  :disabled="item.disabled"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="模板分类" prop="formwork">
              <el-select
                v-model="formData.formwork"
                @change="handleFormwork()"
                default-first-option
                placeholder="请选择模板"
                clearable
                :style="{width: '100%'}"
              >
                <el-option
                  v-for="(item, index) in formworkOptions"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                  :disabled="item.disabled"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24"></el-col>
          <el-col :span="12">
            <el-form-item label="小题数量" prop="optionCount">
              <el-input
                type="number"
                v-model.trim="formData.optionCount"
                placeholder="请输入小题数量"
                clearable
                disabled
                :style="{width: '100%'}"
              ></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="分值" prop="fraction">
              <el-input
                v-model.trim="formData.fraction"
                placeholder="请输入分值"
                type="number"
                clearable
                disabled
                :style="{width: '100%'}"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="大题名称" prop="bigQuestion">
              <el-input
                v-model="formData.bigQuestion"
                type="textarea"
                placeholder="请输入大题名称"
                :autosize="{minRows: 4, maxRows: 4}"
                :style="{width: '100%'}"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <!-- <el-form-item label="上传" prop="img" required> 加上required就是必须要上传图片才能提交-->
            <el-form-item label="上传" prop="img">
              <el-upload
                ref="img"
                :file-list="imgList"
                :action="field101Action"
                list-type="picture"
                :limit="9"
                accept=".jpg, .png"
                :headers="header"
                :before-remove="beforeRemove"
                :on-preview="handlePreview"
                :on-remove="handleRemove"
                :on-success="handleSucces"
                :before-upload="field101BeforeUpload"
              >
                <el-button size="small" type="primary" icon="el-icon-upload">图片上传</el-button>
              </el-upload>
              <el-upload
                ref="img"
                :file-list="fileList"
                :action="field101Action"
                list-type="text"
                :limit="9"
                accept=".pdf, .doc, .docx, .xls, .xlsx"
                :headers="header"
                :before-remove="filebeforeRemove"
                :on-preview="filehandlePreview"
                :on-remove="filehandleRemove"
                :on-success="filehandleSucces"
                :before-upload="filefield101BeforeUpload"
              >
                <el-button size="small" type="primary" icon="el-icon-upload">文件上传</el-button>
              </el-upload>
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label>
              <div class="addbox">
                <div
                  v-for="(item,index) in formData.bankList"
                  :key="item.bankListId"
                  class="noeseleltadd-box"
                >
                  <div class="addbox-item1" v-if="item.beanName=='singleChoiceServiceImpl'">
                    <!-- 小题名称 -->
                    <div class="noeseleltadd-box-smallTopic">
                      <el-col :span="24">
                        <el-form-item label="单选题名称" prop="smallTopic">
                          <el-input
                            v-model="item.smallTopic"
                            type="textarea"
                            placeholder="请输入小题名称"
                            :autosize="{minRows: 4, maxRows: 4}"
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </div>
                    <!-- //分值 -->
                    <div class="noeseleltadd-box-fraction">
                      <el-col :span="12">
                        <el-form-item label="分值" prop="fraction">
                          <el-input
                            v-model.trim="item.fraction"
                            placeholder="请输入分值"
                            type="number"
                            clearable

                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </div>
                    <!-- 选项 -->
                    <div class="noeseleltadd-box-options">
                      <el-col :span="19">
                        <el-form-item label="选项内容" prop="field106">
                          <el-input
                            v-model.trim="item.field106"
                            placeholder="请输入选项内容"
                            clearable
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="5">
                        <el-form-item label-width="1px" label>
                          <el-button
                            type="primary"
                            size="medium"
                            @click="noeseleltaddchose(index)"
                          >添加选项</el-button>
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="选项" prop="field108">
                          <span :style="{color:'#909399'}" v-if="item.options==''">请添加选项</span>
                          <el-radio-group
                            v-model="item.answer"
                            size="medium"
                            @change="oneselectselectchange(index)"
                          >
                            <!-- (file, fileList)=>birefhandleRemove( file, fileList,index) -->
                            <div class="radio">
                              <el-radio
                                class="radio-item"
                                l-radio-group
                                v-for="(item1, index1) in item.options"
                                :key="index1"
                                :label="item1.context"
                                :disabled="item1.disabled"
                              >{{String.fromCharCode(index1 + 65)}}.{{item1.context}}</el-radio>
                            </div>
                          </el-radio-group>
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label-width="100px" label v-if="item.options!=''">
                          <el-button
                            type="danger"
                            size="medium"
                            @click="oneselectdeletechose(index)"
                          >删除选项</el-button>
                        </el-form-item>
                      </el-col>
                    </div>
                    <!-- 答案和详解 -->
                    <div>
                      <el-col :span="24">
                        <el-form-item label="答案" prop="answer">
                          <el-input
                            v-model="item.answer"
                            placeholder="请输入答案"
                            :disabled="true"
                            clearable
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="小题讲解" prop="explains">
                          <el-input
                            v-model="item.explains"
                            placeholder="请输入小题讲解"
                            clearable
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </div>
                    <el-col :span="24">
                      <div>
                        <el-button type="danger" @click="formData.bankList.splice(index, 1)">删除小题</el-button>
                      </div>
                    </el-col>
                  </div>

                  <div class="addbox-item2" v-if="item.beanName=='multipleChoiceServiceImpl'">
                    <!-- 小题名称 -->
                    <div class="moreseleltadd-box-smallTopic">
                      <el-col :span="24">
                        <el-form-item label="多选题名称" prop="smallTopic">
                          <el-input
                            v-model="item.smallTopic"
                            type="textarea"
                            placeholder="请输入小题名称"
                            :autosize="{minRows: 4, maxRows: 4}"
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </div>
                    <!-- //分值 -->
                    <div class="moreseleltadd-box-fraction">
                      <el-col :span="12">
                        <el-form-item label="分值" prop="fraction">
                          <el-input
                            type="number"
                            v-model.trim="item.fraction"
                            placeholder="请输入分值"
                            clearable
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </div>
                    <!-- 评分模式 -->
                    <div>
                      <el-col :span="12">
                        <el-form-item label="评分模式" prop="multipleFlag">
                          <el-select
                            v-model="item.multipleFlag"
                            filterable
                            allow-create
                            default-first-option
                            placeholder="请选择评分模式"
                            clearable
                            :style="{width: '100%'}"
                          >
                            <el-option
                              v-for="(item2, index) in formworkOptions2"
                              :key="index"
                              :label="item2.label"
                              :value="item2.value"
                              :disabled="item2.disabled"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item
                          v-if="item.multipleFlag==2"
                          label="漏选固定分"
                          prop="multipleFraction"
                        >
                          <el-input
                            v-model.trim="item.multipleFraction"
                            placeholder="请输入分值"
                            clearable
                            type="number"
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </div>

                    <!-- 选项 -->
                    <div class="moreseleltadd-box-options">
                      <el-col :span="19">
                        <el-form-item label="选项内容" prop="field106">
                          <el-input
                            v-model.trim="item.field106"
                            placeholder="请输入选项内容"
                            clearable
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="5">
                        <el-form-item label-width="1px" label>
                          <el-button
                            type="primary"
                            size="medium"
                            @click="moreseleltaddchose(index)"
                          >添加选项</el-button>
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="选项" prop="options">
                          <span :style="{color:'#909399'}" v-if="item.options==[]">请添加选项</span>
                          <el-checkbox-group v-model="options" size="medium">
                            <div class="radio">
                              <el-checkbox
                                class="radio-item"
                                v-for="(item1, index1) in item.options"
                                @change="moreselectchange(index1,item)"
                                :key="index1"
                                :label="item1.context"
                                :disabled="item1.disabled"
                              >{{String.fromCharCode(index1 + 65)}}.{{item1.context}}</el-checkbox>
                            </div>
                          </el-checkbox-group>
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label-width="100px" label v-if="item.options!=''">
                          <el-button
                            type="danger"
                            size="medium"
                            @click="moreselectdeletechose(index)"
                          >删除选项</el-button>
                        </el-form-item>
                      </el-col>
                    </div>
                    <!-- 答案和详解 -->
                    <div>
                      <el-col :span="24">
                        <el-form-item label="答案" prop="answer">
                          <el-input
                            v-model="item.answer"
                            placeholder="请输入答案"
                            :disabled="true"
                            clearable
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="小题讲解" prop="explains">
                          <el-input
                            v-model="item.explains"
                            placeholder="请输入小题讲解"
                            clearable
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </div>
                    <el-col :span="24">
                      <div>
                        <el-button type="danger" @click="formData.bankList.splice(index, 1)">删除小题</el-button>
                      </div>
                    </el-col>
                  </div>

                  <div class="addbox-item4" v-if="item.beanName=='judgeServiceImpl'">
                    <!-- 小题名称 -->
                    <div class="noeseleltadd-box-smallTopic">
                      <el-col :span="24">
                        <el-form-item label="判断题名称" prop="smallTopic">
                          <el-input
                            v-model="item.smallTopic"
                            type="textarea"
                            placeholder="请输入小题名称"
                            :autosize="{minRows: 4, maxRows: 4}"
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </div>
                    <!-- //分值 -->
                    <div class="noeseleltadd-box-fraction">
                      <el-col :span="12">
                        <el-form-item label="分值" prop="fraction">
                          <el-input
                            v-model.trim="item.fraction"
                            type="number"
                            placeholder="请输入分值"
                            clearable
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </div>
                    <!-- 选项 -->
                    <div class="noeseleltadd-box-options">
                      <el-col :span="12">
                        <el-form-item label="答案" prop="answer">
                          <el-radio-group v-model="item.answer" size="medium">
                            <el-radio
                              v-for="(item, index) in pointptions"
                              :key="index"
                              :label="item.value"
                              :disabled="item.disabled"
                            >{{item.label}}</el-radio>
                          </el-radio-group>
                        </el-form-item>
                      </el-col>
                    </div>
                    <!-- 答案和详解 -->
                    <div>
                      <el-col :span="24">
                        <el-form-item label="小题讲解" prop="explains">
                          <el-input
                            v-model="item.explains"
                            placeholder="请输入小题讲解"
                            clearable
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </div>

                    <el-col :span="24">
                      <div>
                        <el-button type="danger" @click="formData.bankList.splice(index, 1)">删除小题</el-button>
                      </div>
                    </el-col>
                  </div>

                  <div class="addbox-item5" v-if="item.beanName=='completionServiceImpl'">
                    <!-- 小题名称 -->
                    <div class="noeseleltadd-box-smallTopic">
                      <el-col :span="24">
                        <el-form-item label="填空题名称" prop="smallTopic">
                          <el-input
                            v-model="item.smallTopic"
                            type="textarea"
                            placeholder="请输入小题名称"
                            :autosize="{minRows: 4, maxRows: 4}"
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </div>
                    <!-- //分值 -->
                    <div class="noeseleltadd-box-fraction">
                      <el-col :span="12">
                        <el-form-item label="主观&客观" prop="questionType">
                          <el-radio-group v-model="item.questionType" size="medium">
                            <el-radio
                              v-for="(item, index) in pointptions2"
                              :key="index"
                              :label="item.value"
                              :disabled="item.disabled"
                            >{{item.label}}</el-radio>
                          </el-radio-group>
                        </el-form-item>
                      </el-col>
                    </div>
                    <!-- 选项 -->
                    <div class="noeseleltadd-box-options">
                      <el-col :span="18">
                        <el-form-item label="答案内容" prop="field106">
                          <el-input
                            v-model.trim="item.field106"
                            placeholder="请输入答案内容"
                            clearable
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="3">
                        <el-form-item label-width="1px" prop="point">
                          <el-input
                            type="number"
                            v-model.trim="item.point"
                            placeholder="请输入分数"
                            clearable
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="3">
                        <el-form-item label-width="1px" label>
                          <el-button type="primary" size="medium" @click="bankaddchose(index)">添加答案</el-button>
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="答案" prop="options">
                          <span :style="{color:'#909399'}" v-if="item.options==''">请添加答案</span>
                          <div class="bank-radio">
                            <div
                              class="radio-answer"
                              v-for="(item, index) in item.options"
                              :key="index"
                            >
                              <span>{{item.answer}}</span>
                              <span class="radio-answer-point">({{item.fraction}}分)</span>
                            </div>
                          </div>
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label-width="100px" label v-if="item.options!=''">
                          <el-button
                            type="danger"
                            size="medium"
                            @click="bankdeletechose(index)"
                          >删除填空</el-button>
                        </el-form-item>
                      </el-col>
                    </div>
                    <!-- 答案和详解 -->
                    <div>
                      <el-col :span="24">
                        <el-form-item label="小题讲解" prop="explains">
                          <el-input
                            v-model="item.explains"
                            placeholder="请输入小题讲解"
                            clearable
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </div>
                    <el-col :span="24">
                      <div>
                        <el-button type="danger" @click="formData.bankList.splice(index, 1)">删除小题</el-button>
                      </div>
                    </el-col>
                  </div>
                  <div class="addbox-item3" v-if="item.beanName=='shortAnswerServiceImpl'">
                    <!-- 小题名称 -->
                    <div class="noeseleltadd-box-smallTopic">
                      <el-col :span="24">
                        <el-form-item label="简答题名称" prop="smallTopic">
                          <el-input
                            v-model="item.smallTopic"
                            type="textarea"
                            placeholder="请输入小题名称"
                            :autosize="{minRows: 4, maxRows: 4}"
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </div>
                    <!-- //分值 -->
                    <div class="noeseleltadd-box-fraction">
                      <el-col :span="12">
                        <el-form-item label="分值" prop="fraction">
                          <el-input
                            v-model.trim="item.fraction"
                            type="number"
                            placeholder="请输入分值"
                            clearable
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </div>
                    <!-- 选项 -->
                    <div class="noeseleltadd-box-options">
                      <el-col :span="24">
                        <!-- <el-form-item label="上传" prop="img" required> 加上required就是必须要上传图片才能提交-->
                        <!-- headers设置请求头 -->
                        <el-form-item label="上传" prop="img">
                          <el-upload
                            ref="img"
                            :file-list="item.imgList"
                            :action="field101Action"
                            list-type="picture"
                            :limit="9"
                            accept=".jpg, .png"
                            :headers="header"
                            :before-remove="birefbeforeRemove"
                            :on-preview="birefhandlePreview"
                            :on-remove="(file, fileList)=>birefhandleRemove( file, fileList,index)"
                            :on-success="(response, file, fileList)=>birefhandleSucces(response, file, fileList,index)"
                            :before-upload="bireffield101BeforeUpload"
                          >
                            <el-button size="small" type="primary" icon="el-icon-upload">图片上传</el-button>
                          </el-upload>
                          <el-upload
                            ref="img"
                            :file-list="item.fileList"
                            :action="field101Action"
                            list-type="text"
                            :limit="9"
                            accept=".pdf, .doc, .docx, .xls, .xlsx"
                            :headers="header"
                            :before-remove="bireffilebeforeRemove"
                            :on-preview="bireffilehandlePreview"
                            :on-remove="(file, fileList)=>bireffilehandleRemove( file, fileList,index) "
                            :on-success="(response, file, fileList)=>bireffilehandleSucces(response, file, fileList,index)"
                            :before-upload="bireffilefield101BeforeUpload"
                          >
                            <el-button size="small" type="primary" icon="el-icon-upload">文件上传</el-button>
                          </el-upload>
                        </el-form-item>
                      </el-col>
                    </div>
                    <!-- 答案和详解 -->
                    <div>
                      <el-col :span="24">
                        <el-form-item label="答案" prop="answer">
                          <el-input
                            v-model="item.answer"
                            type="textarea"
                            placeholder="请输入答案"
                            :autosize="{minRows: 4, maxRows: 4}"
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="24">
                        <el-form-item label="小题讲解" prop="explains">
                          <el-input
                            v-model="item.explains"
                            placeholder="请输入小题讲解"
                            clearable
                            :style="{width: '100%'}"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </div>
                    <el-col :span="24">
                      <div>
                        <el-button type="danger" @click="formData.bankList.splice(index, 1)">删除小题</el-button>
                      </div>
                    </el-col>
                  </div>
                </div>
              </div>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="添加小题" prop="keytypeof">
              <el-select
                v-model="keytypeof"
                filterable
                allow-create
                default-first-option
                placeholder="请选择小题类型"
                clearable
                :style="{width: '100%'}"
              >
                <el-option
                  v-for="(item2, index) in typeOptions"
                  :key="index"
                  :label="item2.dictLabel"
                  :value="item2.dictValue"
                  :disabled="item2.disabled"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-button type="primary" @click="chosetype(keytypeof)">添加小题</el-button>
          </el-col>
          <el-col :span="24">
            <el-form-item label="考察知识点" prop="investigateKnow">
              <el-input
                v-model="formData.investigateKnow"
                placeholder="请输入考察知识点"
                clearable
                :style="{width: '100%'}"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="一级知识点" prop="knowledgeA">
              <el-input
                v-model="formData.knowledgeA"
                placeholder="请输入一级知识点"
                clearable
                :style="{width: '100%'}"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="二级知识点" prop="knowledgeB">
              <el-input
                v-model="formData.knowledgeB"
                placeholder="请输入二级知识点"
                clearable
                :style="{width: '100%'}"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="认知分类" prop="categorization">
              <el-input
                v-model="formData.categorization"
                placeholder="请输入认知分类"
                clearable
                :style="{width: '100%'}"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="内容相关性" prop="correlation">
              <el-input
                v-model="formData.correlation"
                placeholder="请输入内容相关性"
                clearable
                :style="{width: '100%'}"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item size="large">
              <el-button type="primary" @click="dialogsubmitForm">提交</el-button>
              <el-button @click="dailogresetForm">重置</el-button>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
  </div>
</template>
<script>
  import { getToken } from "@/utils/auth";
  import {
    listQuestionbank,
    getQuestionbank,
    delQuestionbank,
    addQuestionbank,
    updateQuestionbank,
    exportQuestionbank,
  } from "@/api/topic/questionbank";
  import {
    addMoreSelect,
    search,
    changeMoreSelect,
    getFormark,
    deleQuestion,
    deleQuestions,
  } from "@/api/topic/moerselect";
  import { listTemplate } from "@/api/topic/template";
  import showDetail from "@/components/showDetail";
  import { listQuestionBankType} from "@/api/topic/QuestionBankType";
  import Editor from "@/components/Editor";
  export default {
    name: "moreselect",
    components: { showDetail: showDetail },
    components: { Editor: Editor },
    // components: { Editor: Editor , showDetail: showDetail },
    data() {
      return {
        propdata: [],
        keytypeof: "",
        myaddkey: "",
        oneselectlistTodoId: 0,
        formData: {
          type: "大题",
          beanName: "bigQuestionServiceImpl",
          bankList: [],
          imgUrl: "",
          fileUrl: "",
          fraction: null,
          optionCount: 0,
          bankTypeId:null,
          difficulty: undefined,
          bigQuestion: undefined,
          investigateKnow: undefined,
          knowledgeA: undefined,
          knowledgeB: undefined,
          noticeContent: [],
        },
        oneselectoptions: [],
        field101Action: "https://jsonplaceholder.typicode.com/posts/",
        imgList: [],
        selectoptions: [],
        dialogrules: {
          bankTypeId:[
            {
              required: true,
              message: "请选择所属题库",
              trigger: "blur",
            },
          ],
          formwork:[
            {
              required: true,
              message: "请输入或选择模板分类",
              trigger: "blur",
            },
          ],
          difficulty:[{
            required: true,
            message: "请选择难易程度",
            trigger: "change",
          }
          ],
          optionCount: [
            {
              required: true,
              message: "请输入小题数量",
              trigger: "change",
            },
          ],

          fraction: [
            {
              required: true,
              message: "请输入分数",
              trigger: "change",
            },
          ],
          bigQuestion: [
            {
              required: true,
              message: "请输入大题",
              trigger: "change",
            },
          ],
          field103: [
            {
              required: true,
              message: "请输入难易程度",
              trigger: "change",
            },
          ],
          difficulty: [
            {
              required: true,
              message: "选择题目难度",
              trigger: "blur",
            },
          ],
          field110: [
            {
              required: true,
              message: "请输入考察知识点",
              trigger: "blur",
            },
          ],
          field111: [
            {
              required: true,
              message: "请输入一级知识点",
              trigger: "blur",
            },
          ],
          field112: [
            {
              required: true,
              message: "请输入二级知识点",
              trigger: "blur",
            },
          ],
          field113: [
            {
              required: true,
              message: "请输入认知分类",
              trigger: "blur",
            },
          ],
          field114: [
            {
              required: true,
              message: "请输入内容相关性",
              trigger: "blur",
            },
          ],
        },
        formworkOptions3: [],
        field103Options: [
          {
            label: "1",
            value: 1,
          },
          {
            label: "2",
            value: 2,
          },
          {
            label: "3",
            value: 3,
          },
          {
            label: "4",
            value: 4,
          },
          {
            label: "5",
            value: 5,
          },
          {
            label: "6",
            value: 6,
          },
          {
            label: "7",
            value: 7,
          },
          {
            label: "8",
            value: 8,
          },
          {
            label: "9",
            value: 9,
          },
          {
            label: "10",
            value: 10,
          },
        ],
        formworkOptions: [],
        pointptions: [
          {
            label: "对",
            value: true,
          },
          {
            label: "错",
            value: false,
          },
        ],
        options: [],
        pointptions2: [
          {
            label: "主观",
            value: 0,
          },
          {
            label: "客观",
            value: 1,
          },
        ],
        formworkOptions2: [
          {
            label: "全对给分",
            value: 0,
          },
          {
            label: "漏选给分",
            value: 1,
          },
          {
            label: "漏选给固定分",
            value: 2,
          },
        ],
        selectoptions: [],
        header: { Authorization: "Bearer " + getToken() },
        field101Action: process.env.VUE_APP_BASE_API + "/common/upload",
        imgList: [],
        fileList: [],
        //图片和文件的前缀
        exhead: "http://10.168.100.154" + process.env.VUE_APP_BASE_API,
        // 遮罩层
        loading: true,
        // 导出遮罩层
        exportLoading: false,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 是否显示预览内容
        Showdetail: false,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 题库
        questionBankType:[],
        // 基本题库管理表格数据
        questionbankList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 题目类型字典
        typeOptions: [],
        // 认知分类字典
        categorizationOptions: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          bigQuestion: null,
          type: "大题",
          beanName: "bigQuestionServiceImpl",
          optionCount: null,
          answer: null,
          fraction: null,
          bankTypeId:null,
          knowledgeA: null,
          knowledgeB: null,
          investigateKnow: null,
          categorization: null,
          difficulty: null,
          correlation: null,
          formwork: null,
          createTime: null,
          createBy: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {},
      };
    },
    created() {
      this.getList();
      this.getFormarkdata();
      this.getDicts("question_type").then((response) => {
        response.data.splice(response.data.length - 1, 1);
        this.typeOptions = response.data;
      });

      this.getDicts("topic_categorization").then((response) => {
        this.categorizationOptions = response.data;
      });
    },
    methods: {
      //提交模板类型
      handleFormwork() {
        console.log("模板类型",this.formData.formwork)
        for (let i = 0; i <this.formworkOptions.length; i++) {
          if(this.formworkOptions[i].value ==this.formData.formwork){
            this.formData.optionCount=this.formworkOptions[i].count
            this.formData.fraction=this.formworkOptions[i].questionScore
            this.formData.questionTemplateId=this.formworkOptions[i].id
          }
        }
      },
      //选择题型
      chosetype(keytypeof) {
        if (
          this.formData.bankList.length >= parseFloat(this.formData.optionCount)
        ) {
          this.$message.error("小题数量已满");
          return;
        }
        let type = "";
        if (keytypeof == "singleChoiceServiceImpl") {
          type = "单项选择题";
        } else if (keytypeof == "multipleChoiceServiceImpl") {
          type = "多项选择题";
        } else if (keytypeof == "shortAnswerServiceImpl") {
          type = "简答题";
        } else if (keytypeof == "judgeServiceImpl") {
          type = "判断题";
        } else if (keytypeof == "completionServiceImpl") {
          type = "填空题";
        } else {
          return;
        }
        this.add(keytypeof, type);
      },
      //添加单选
      add(beanName, type) {
        if(this.formData.formwork==null){
          this.$message.error("请先选择模板");
          return
        }
        if(this.formData.optionCount<this.formData.bankList.length){
          this.$message.error("已经达到最大小题数");
          return
        }

        this.formData.bankList.push({
          bankListId: this.oneselectlistTodoId++,
          options: [],
          imgList: [],
          fileList: [],
          beanName: beanName,
          type: type,
          smallTopic: null,
          explains: null,
          answer: null,
          fraction:0,
          num: null,
          field106: null,
          optionCount: null,
          multipleFlag: null,
          multipleFraction: 0,
          tempdata: null,
          imgUrl: "",
          fileUrl: "",
          point: null,
          questionType: null,
        });
      },

      noeseleltaddchose(index) {
        let myadd = 0;
        if (!this.formData.bankList[index].field106) {
          this.$message.error("请输入选项内容");
          return;
        } else {
          let i = 0;
          for (i; i < this.formData.bankList[index].options.length; i++) {
            if (
              this.formData.bankList[index].options[i].value ==
              this.formData.bankList[index].field106
            ) {
              this.$message.error("该选项已存在");
              myadd = 1;
              return;
            }
          }
        }
        if (myadd == 1) {
          return;
        }
        const data = {
          context: this.formData.bankList[index].field106,
          value: this.formData.bankList[index].field106,
          keyTrue: false,
          num: String.fromCharCode(
            this.formData.bankList[index].options.length + 65
          ),
        };

        this.formData.bankList[index].options.push(data);
        this.formData.bankList[index].optionCount++;
        this.formData.bankList[index].field106 = "";
      },
      //单选删除
      oneselectdeletechose(index) {
        this.formData.bankList[index].options.splice(
          this.formData.bankList[index].options.length - 1,
          1
        );
        this.formData.bankList[index].answer=null
        this.formData.bankList[index].optionCount--;
      },
      // 单选正确答案
      oneselectselectchange(index) {
        const that = this;
        const index2 = index;
        this.formData.bankList[index].options.forEach(function (value, index) {
          if (that.formData.bankList[index2].answer == value.value) {
            that.formData.bankList[index2].options[index].keyTrue = true;
          } else {
            that.formData.bankList[index2].options[index].keyTrue = false;
          }
        });
      },

      // 多选增加选项
      moreseleltaddchose(index) {
        let myadd = 0;
        if (!this.formData.bankList[index].field106) {
          this.$message.error("请输入选项内容");
          return;
        } else {
          let i = 0;
          for (i; i < this.formData.bankList[index].options.length; i++) {
            if (
              this.formData.bankList[index].options[i].value ==
              this.formData.bankList[index].field106
            ) {
              this.$message.error("该选项已存在");
              myadd = 1;
              return;
            }
          }
        }
        if (myadd == 1) {
          return;
        }
        const data = {
          context: this.formData.bankList[index].field106,
          value: this.formData.bankList[index].field106,
          keyTrue: false,
          num: String.fromCharCode(
            this.formData.bankList[index].options.length + 65
          ),
        };
        this.formData.bankList[index].options.push(data);
        this.formData.bankList[index].field106 = "";
        this.formData.bankList[index].optionCount++;
      },
      //多选删除
      moreselectdeletechose(index) {
        this.formData.bankList[index].options.splice(
          this.formData.bankList[index].options.length - 1,
          1
        );
        this.formData.bankList[index].optionCount++;
      },
      //多选正确答案
      moreselectchange(index, item) {
        item.options[index].keyTrue = !item.options[index].keyTrue;
        item.answer = "";
        for (let i = 0; i < item.options.length; i++) {
          if (item.options[i].keyTrue) {
            item.answer += String.fromCharCode(i + 65);
          }
        }
        console.log(item.options,"选择后的值")
      },

      // 填空增加选项
      bankaddchose(index) {
        if (!this.formData.bankList[index].field106) {
          this.$message.error("请输入选项内容");
          return;
        }
        if (this.formData.bankList[index].point == null) {
          this.$message.error("请输入填空分值");
          return;
        }
        if (parseFloat(this.formData.bankList[index].point) <= 0) {
          this.$message.error("分值必须大于0");
          return;
        }
        if (this.myaddkey == 1) {
          return;
        } else {
          const data = {
            answer: this.formData.bankList[index].field106,
            fraction: parseFloat(this.formData.bankList[index].point),
          };
          this.formData.bankList[index].field106 = "";
          this.formData.bankList[index].point = null;
          this.formData.bankList[index].optionCount =
            this.formData.bankList[index].options.length;
          this.formData.bankList[index].options.push(data);
        }
      },
      //填空删除
      bankdeletechose(index) {
        this.formData.bankList[index].options.splice(
          this.formData.bankList[index].options.length - 1,
          1
        );
        this.formData.bankList[index].optionCount =
          this.formData.bankList[index].options.length;
      },
      //获取模板类型
      getFormarkdata() {
        this.loading = true;
        const data = {
          beanName: this.formData.beanName,
        };
        listTemplate(data).then(response => {
          this.formworkOptions=response.rows
          for (let i = 0; i < response.rows.length; i++) {
            this.formworkOptions[i].label=response.rows[i].name
            this.formworkOptions[i].value=response.rows[i].name
          }
        });
        // getFormark(data).then((response) => {
        //   for (let i = 0; i < response.length; i++) {
        //     this.formworkOptions[i] = {
        //       label: response[i],
        //       value: response[i],
        //     };
        //   }
        // });
      },
      //移除图片前事件
      beforeRemove(file, fileList) {
        return this.$confirm(`确定移除 ${file.name}？`);
      },
      //上传图片成功
      handleSucces(response, file, fileList) {
        this.formData.imgUrl += response.fileName + ",";
      },
      //图片预览
      handlePreview(file) {},
      //移除图片
      handleRemove(file, fileList) {
        let imgtemplatedata = [];
        imgtemplatedata = this.formData.imgUrl.split(",");
        this.formData.imgUrl = "";
        for (let i = 0; i <= imgtemplatedata.length - 2; i++) {
          if (file.response.fileName == imgtemplatedata[i]) {
          } else {
            this.formData.imgUrl += imgtemplatedata[i] + ",";
          }
        }
      },
      //选择图片
      field101BeforeUpload(file) {},
      //移除图片前事件
      beforeRemove(file, fileList) {
        return this.$confirm(`确定移除 ${file.name}？`);
      },
      //上传文件成功
      filehandleSucces(response, file, fileList) {
        this.formData.fileUrl += response.fileName + ",";
      },
      //文件预览
      filehandlePreview(file) {},
      //移除文件
      filehandleRemove(file, fileList) {
        let imgtemplatedata = [];
        imgtemplatedata = this.formData.fileUrl.split(",");
        this.formData.fileUrl = "";
        for (let i = 0; i <= imgtemplatedata.length - 2; i++) {
          if (file.response.fileName == imgtemplatedata[i]) {
          } else {
            this.formData.fileUrl += imgtemplatedata[i] + ",";
          }
        }
      },
      //选择文件
      filefield101BeforeUpload(file) {},
      //移除文件事件
      filebeforeRemove(file, fileList) {
        return this.$confirm(`确定移除 ${file.name}？`);
      },

      //简答题文件图片上传
      //移除图片前事件
      birefbeforeRemove(file, fileList) {
        return this.$confirm(`确定移除 ${file.name}？`);
      },
      //上传图片成功
      birefhandleSucces(response, file, fileList, index) {
        this.formData.bankList[index].imgUrl += response.fileName + ",";
      },
      //图片预览
      birefhandlePreview(file) {},
      //移除图片
      birefhandleRemove(file, fileList, index) {
        let imgtemplatedata = [];
        imgtemplatedata = this.formData.bankList[index].imgUrl.split(",");
        this.formData.bankList[index].imgUrl = "";
        for (let i = 0; i <= imgtemplatedata.length - 2; i++) {
          if (file.response.fileName == imgtemplatedata[i]) {
          } else {
            this.formData.bankList[index].imgUrl += imgtemplatedata[i] + ",";
          }
        }
      },
      //选择图片
      bireffield101BeforeUpload(file) {},
      //移除图片前事件
      birefbeforeRemove(file, fileList) {
        return this.$confirm(`确定移除 ${file.name}？`);
      },
      //上传文件成功
      bireffilehandleSucces(response, file, fileList, index) {
        this.formData.bankList[index].fileUrl += response.fileName + ",";
      },
      //文件预览
      bireffilehandlePreview(file) {},
      //移除文件
      bireffilehandleRemove(file, fileList, index) {
        let imgtemplatedata = [];
        imgtemplatedata = this.formData.bankList[index].fileUrl.split(",");
        this.formData.bankList[index].fileUrl = "";
        for (let i = 0; i <= imgtemplatedata.length - 2; i++) {
          if (file.response.fileName == imgtemplatedata[i]) {
          } else {
            this.formData.bankList[index].fileUrl += imgtemplatedata[i] + ",";
          }
        }
      },
      //选择文件
      bireffilefield101BeforeUpload(file) {},
      //移除文件事件
      bireffilebeforeRemove(file, fileList) {
        return this.$confirm(`确定移除 ${file.name}？`);
      },

      //表单提交
      dialogsubmitForm() {
        console.log(this.formData);
        if (this.formData.bankList == []) {
          this.$message.error("请添加小题");
          return;
        } else if (
          this.formData.bankList.length != parseFloat(this.formData.optionCount)
        ) {
          this.$message.error("小题数量不对");
          return;
        }
        //分数校验

        this.formData.fraction = parseFloat(this.formData.fraction);
        let totalscore=0
        //表单校验
        let subkey = 0;
        const that = this;
        for (let i = 0; i < this.formData.bankList.length; i++) {
          this.formData.bankList[i].fraction = parseFloat(
            this.formData.bankList[i].fraction
          );
          this.formData.bankList[i].multipleFraction = parseFloat(
            this.formData.bankList[i].multipleFraction
          );
          console.log(this.formData.bankList[i].smallTopic)
          if (this.formData.bankList[i].smallTopic ==null) {
            that.$message.error("小题名称不能为空");
            subkey=1
            return
          } else if (this.formData.bankList[i].fraction < 0) {
            that.$message.error("分数必须大于0");
            subkey=1
            return
          }
          if(this.formData.bankList[i].type=="填空题"){//填空题校验
            for(let j=0;j<this.formData.bankList[i].options.length;j++){
              totalscore+=this.formData.bankList[i].options[j].fraction
            }
            if(this.formData.bankList[i].questionType==null){
              that.$message.error("请选择填空题主观客观");
              subkey=1
              return
            }
            if(this.formData.bankList[i].options.length==0){
              that.$message.error("请添加填空题答案");
              subkey=1
              return
            }
          }else{
            totalscore+=this.formData.bankList[i].fraction
          }

          if(this.formData.bankList[i].type=="单项选择题"){//单选小题校验
            if(this.formData.bankList[i].fraction<=0){
              that.$message.error("单选题分值大于0");
              subkey=1
              return
            }
            if(this.formData.bankList[i].options.length<2){
              that.$message.error("请添加至少2个单选题选项");
              subkey=1
              return
            }
            if(this.formData.bankList[i].answer==null){
              that.$message.error("请选择单选题答案");
              subkey=1
              return
            }
          }
          if(this.formData.bankList[i].type=="多项选择题"){//多选小题校验
            if(this.formData.bankList[i].fraction<=0){
              that.$message.error("多选题分值大于0");
              subkey=1
              return
            }
            if(this.formData.bankList[i].multipleFlag==null){
              that.$message.error("请选择多选题评分模式");
              subkey=1
              return
            }
            if(this.formData.bankList[i].multipleFlag==2){
              console.log(this.formData.bankList[i].multipleFraction)
              if(this.formData.bankList[i].multipleFraction==0){
                that.$message.error("请输入多选题漏选固定分");
                subkey=1
                return
              }
              if(this.formData.bankList[i].multipleFraction>=this.formData.bankList[i].fraction){
                that.$message.error("多选题漏选分值必须小于多选分数");
                subkey=1
                return
              }
            }
            if(this.formData.bankList[i].options.length<2){
              that.$message.error("多选题请添加至少2个多选题选项");
              subkey=1
              return
            }
            if(this.formData.bankList[i].answer==null){
              that.$message.error("请选择多选题答案");
              subkey=1
              return
            }
          }
          if(this.formData.bankList[i].type=="简答题"){//简答小题校验
            if(this.formData.bankList[i].fraction<=0){
              that.$message.error("简答题分值大于0");
              subkey=1
              return
            }
            if(this.formData.bankList[i].answer==null){
              that.$message.error("请输入简答题答案");
              subkey=1
              return
            }

          }
          if(this.formData.bankList[i].type=="判断题"){//判断小题校验
            if(this.formData.bankList[i].fraction<=0){
              that.$message.error("判断题分值大于0");
              subkey=1
              return
            }
            if(this.formData.bankList[i].answer==null){
              that.$message.error("请选择判断题答案");
              subkey=1
              return
            }
          }


        }
        if(totalscore!=this.formData.fraction){//校验分数是否一致
          that.$message.error("小题分值总和与大题总分不一致");
          subkey=1
          return
        }
        this.$refs["elForm"].validate((valid) => {
          if (subkey == 1) {
            return;
          } else if (valid) {
              console.log("新增大题",this.formData);
              addMoreSelect(this.formData).then((response) => {
                this.formData.id=response
                this.$emit('getFormData',this.formData)
                this.msgSuccess("添加大题成功");
                this.open = false;
                this.dailogresetForm()
              });
          }
          // TODO 提交表单
        });
      },
      dailogresetForm() {
        this.formData = {
          type: "大题",
          beanName: "bigQuestionServiceImpl",
          bigQuestion: null,
          bankList: [],
          fraction: null,
          bankTypeId:undefined,
          imgUrl: "",
          fileUrl: "",
          difficulty: undefined,
          bigQuestion: undefined,
          investigateKnow: undefined,
          knowledgeA: undefined,
          knowledgeB: undefined,
          noticeContent: [],
        };
        this.imgList = [];
        this.fileList = [];
      },
      /** 查询基本题库管理列表 */
      getList() {
        this.loading = true;
        listQuestionbank(this.queryParams).then((response) => {
          this.questionbankList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
        listQuestionBankType().then(response => {
          this.questionBankType=response.rows

        });
      },
      // 题目类型字典翻译
      typeFormat(row, column) {
        return this.selectDictLabel(this.typeOptions, row.type);
      },
      // 认知分类字典翻译
      categorizationFormat(row, column) {
        return this.selectDictLabel(
          this.categorizationOptions,
          row.categorization
        );
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          parentId: null,
          personId: null,
          bigQuestion: null,
          smallTopic: null,
          type: null,
          optionCount: null,
          answer: null,
          fraction: null,
          knowledgeA: null,
          knowledgeB: null,
          investigateKnow: null,
          categorization: null,
          difficulty: null,
          correlation: null,
          formwork: null,
          createTime: null,
          createBy: null,
          updateTime: null,
          updateBy: null,
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map((item) => item.id);
        this.single = selection.length !== 1;
        this.multiple = !selection.length;
      },
      /** 预览按钮操作 */
      handleShow(row) {
        this.propdata = row;
        this.Showdetail = true;
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.dailogresetForm();
        this.open = true;
        this.title = "添加大题题库管理";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        this.dailogresetForm();
        const data = {
          bankId: row.id || this.ids[0],
          beanName: "bigQuestionServiceImpl",
        };
        search(data).then((response) => {
          this.formData = response;
          console.log("修改时值", this.formData);
          this.imgList = [];
          this.fileList = [];
          let imgtemplatedata = [];
          let filetemplatedata = [];
          if (this.formData.fileUrl) {
            filetemplatedata = this.formData.fileUrl.split(",");
          }
          if (this.formData.imgUrl) {
            imgtemplatedata = this.formData.imgUrl.split(",");
          }
          const that = this;
          for (let i = 0; i <= imgtemplatedata.length - 2; i++) {
            const data = {
              uid: i,
              name: imgtemplatedata[i],
              url: this.exhead + imgtemplatedata[i],
              response: {
                fileName: imgtemplatedata[i],
              },
            };
            this.imgList[i] = data;
          }
          for (let i = 0; i <= filetemplatedata.length - 2; i++) {
            const data = {
              uid: i,
              url: this.exhead + filetemplatedata[i],
              name: filetemplatedata[i],
              response: {
                fileName: filetemplatedata[i],
              },
            };
            this.fileList[i] = data;
          }

          for (let i = 0; i < this.formData.bankList.length; i++) {
            this.formData.bankList[i].field108 = "";
            if (this.formData.bankList[i].beanName == "singleChoiceServiceImpl") {
              for (let j = 0; j < this.formData.bankList[i].options.length; j++) {
                this.formData.bankList[i].options[j].value =
                  this.formData.bankList[i].options[j].context;
                // this.formData.bankList[i].options[j].keyTrue = false;
              }
            } else if (
              this.formData.bankList[i].beanName == "multipleChoiceServiceImpl"
            ) {
              for (let j = 0; j < this.formData.bankList[i].options.length; j++) {
                //this.formData.bankList[i].options[j].keyTrue = false;
                if(this.formData.bankList[i].options[j].keyTrue){
                  this.options[j]=this.formData.bankList[i].options[j].context
                }
              }
            } else if (this.formData.bankList[i].beanName == "judgeServiceImpl") {
              this.formData.bankList[i].answer = null;
            } else if (
              this.formData.bankList[i].beanName == "shortAnswerServiceImpl"
            ) {
              this.formData.bankList[i].imgList = [];
              this.formData.bankList[i].fileList = [];
              let showimgtemplatedata = [];
              let showfiletemplatedata = [];
              if (this.formData.bankList[i].fileUrl) {
                showfiletemplatedata =
                  this.formData.bankList[i].fileUrl.split(",");
                for (let j = 0; j <= showfiletemplatedata.length - 2; j++) {
                  const data = {
                    uid: j,
                    url: this.exhead + showfiletemplatedata[j],
                    name: showfiletemplatedata[j],
                    response: {
                      fileName: showfiletemplatedata[j],
                    },
                  };
                  this.formData.bankList[i].fileList[j] = data;
                }
              }

              if (this.formData.bankList[i].imgUrl) {
                showimgtemplatedata = this.formData.bankList[i].imgUrl.split(",");
                for (let j = 0; j <= showimgtemplatedata.length - 2; j++) {
                  const data = {
                    uid: j,
                    name: showimgtemplatedata[j],
                    url: this.exhead + showimgtemplatedata[j],
                    response: {
                      fileName: showimgtemplatedata[j],
                    },
                  };
                  this.formData.bankList[i].imgList[j] = data;
                }
              }
              const that = this;
            }
          }

          this.open = true;
          this.title = "修改大题题库管理";
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate((valid) => {
          if (valid) {
            if (this.form.id != null) {
              updateQuestionbank(this.form).then((response) => {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              addQuestionbank(this.form).then((response) => {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        let data = {};
        if (typeof ids == "string") {
          data = {
            bankId: ids,
            beanName: this.formData.beanName,
          };
          this.$confirm(
            '是否确认删除大题题库管理编号为"' + ids + '"的数据项?',
            "警告",
            {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
            }
          )
            .then(function () {
              return deleQuestion(data);
            })
            .then(() => {
              this.getList();
              this.msgSuccess("删除成功");
            })
            .catch(() => {});
        } else {
          data = {
            bankIds: ids,
            beanName: this.formData.beanName,
          };
          this.$confirm(
            '是否确认删除大题题库管理编号为"' + ids + '"的数据项?',
            "警告",
            {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
            }
          )
            .then(function () {
              return deleQuestions(data);
            })
            .then(() => {
              this.getList();
              this.msgSuccess("删除成功");
            })
            .catch(() => {});
        }
      },
      /** 导出按钮操作 */
      handleExport() {
        const queryParams = this.queryParams;
        this.$confirm("是否确认导出所有大题库管理数据项?", "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.exportLoading = true;
            return exportQuestionbank(queryParams);
          })
          .then((response) => {
            this.download(response.msg);
            this.exportLoading = false;
          })
          .catch(() => {});
      },
    },
  };
</script>
<style>
  .radio {
    display: flex;
    flex-direction: column;
  }
  .radio-item {
    margin-top: 10px;
  }
  .icon {
    display: inline;
    margin-left: 20px;
  }
  .noeseleltadd-box {
    border: 1px solid #e4e7ed;
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
  }
  .noeseleltadd-box-smallTopic {
    margin-top: 10px;
  }
  .noeseleltadd-box-fraction {
    margin-top: 10px;
  }
  .noeseleltadd-box-options {
    margin-top: 10px;
  }

  .moreseleltadd-box {
    border: 1px solid #e4e7ed;
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
  }
  .moreseleltadd-box-smallTopic {
    margin-top: 10px;
  }
  .moreseleltadd-box-fraction {
    margin-top: 10px;
  }
  .moreseleltadd-box-options {
    margin-top: 10px;
  }
</style>








